from appium import webdriver


class DeviceManager:
    _instance = None

    @classmethod
    def get_driver(cls, config):
        if not cls._instance:
            desired_caps = {
                "platformName": config['platformName'],
                "deviceName": config['deviceName'],
                "appPackage": config['appPackage'],
                "appActivity": config['appActivity'],
                "noReset": config['noReset']
            }
            cls._instance = webdriver.Remote(config['server_url'], desired_caps)
        return cls._instance
